package OrderService

import (
	"context"
	"gdshop-font-api-go/app/request/OrderReq"
	"gdshop-font-api-go/library/response"
	"gdshop-font-api-go/library/tools"
	"gdshop-font-api-go/rpc/request"
	"gdshop-font-api-go/rpc/service"
	_ "github.com/hprose/hprose-golang/rpc/fasthttp"
)

// 用户支付订单
func SubmitPay(ctx context.Context, parames *OrderReq.SubmitPay) *response.JsonResponse {
	/*c := tools.GetBackClient().Ctx(ctx)

	data := g.Map{
		"member_id": parames.MemberId,
		"order_id":  parames.OrderId,
		"payment":   parames.Payment,
	}
	hash := guid.S()
	g.Redis().Do("SETEX", "SubmitPay:"+hash, 60, data)
	var fanhui *response.JsonResponse
	err := c.GetVar(g.Cfg().GetString("back_api.SubmitPayUrl"), g.Map{
		"hash": hash,
	}).Scan(&fanhui)
	if err != nil {
		return response.FailByRequestMessage(nil, err.Error())
	}

	return fanhui*/

	client := tools.GetRpcClient()
	var orderService *service.OrderService
	client.UseService(&orderService)
	jieguo, err := orderService.MemberPay(&request.MemberPay{
		OrderId:  parames.OrderId,
		MemberId: parames.MemberId,
		Payment:  parames.Payment,
	})
	if err != nil {
		return response.RpcFailByRequestMessage(nil, err.Error())
	}

	return jieguo
}
